<?php
$semester = array();

foreach($data->result_array() as $row){
	$semester = $row;
}


?>
	<!-- BEGIN PAGE -->
	<div class="page-content">
         <!-- BEGIN PAGE CONTAINER-->        
         <div class="container-fluid">
            <!-- BEGIN PAGE HEADER-->
			<div class="row-fluid">
				<div class="span12"> 
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->			
					<h3 class="page-title">
						Form Semester <small> menambah dan mengedit semester</small>
					</h3>
					<ul class="breadcrumb">
						<li>
							<i class="icon-cogs"></i>
							Pengaturan Awal	
							<i class="icon-angle-right"></i>
						</li>
						<li>
							<a href="<?php echo base_url()?>semester">Semester</a>		
							<i class="icon-angle-right"></i>
						</li>
						<li>Form Semester</li>	
					</ul>
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->          
            <div class="row-fluid">
               <div class="span12">
                  <!-- BEGIN SAMPLE TABLE PORTLET-->
                  <div class="portlet box green">
                     <div class="portlet-title">
                        <div class="caption"><i class="icon-cogs"></i>Form Semester</div>
                     </div>
                     <div class="portlet-body form">
                        <form id="form-semester" class="form-horizontal form-bordered form-row-stripped" action="" method="post">
							<div class="control-group">
								<label class="control-label">Departemen</label>
                              
								<div class="controls">
									<input type="hidden" name="data[departemen_id]" value="<?php echo $departemen_id ?>" />
								<?php
									foreach($departemen->result_array() as $row){
										if($departemen_id == $row['departemen_id']){
											echo '<input class="m-wrap span6"type="text" value="'.$row['nama'].'" readonly="readonly" />';
										}
									}
								?>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" >Semester:</label>
								<div class="controls">
									<input class="m-wrap span6" id="semester" type="text" name="data[semester]" value="<?php echo isset($semester['semester'])?$semester['semester']:''?>" required />
								</div>
							</div>
						   <div class="control-group">
                              <label class="control-label">Aktif</label>
                              <div class="controls">
                                 <label class="radio">
                                 <input type="radio" name="data[aktif]" value=1  <?php echo (isset($semester['aktif']) &&  $semester['aktif'] == 1)?'checked="checked"':''?> checked />
                                 Ya
                                 </label>
                                 <label class="radio">
                                 <input type="radio" name="data[aktif]" value=0 <?php echo (isset($semester['aktif']) &&  $semester['aktif'] == 0)?'checked="checked"':''?> />
                                 Tidak
                                 </label>                                
                              </div>
                           </div>
						   <div class="control-group">
                              <label class="control-label">Keterangan</label>
                              <div class="controls">
                                 <textarea class="span6 m-wrap" name="data[keterangan]" rows="3"><?php echo isset($semester['keterangan'])?$semester['keterangan']:''?></textarea>
                              </div>
                           </div>
							<div class="form-actions">
							   <button type="submit" class="btn blue"><i class="icon-ok"></i> SIMPAN</button>
							   <a href="<?php echo base_url()?>semester" class="btn">BATAL</a>
							</div>
						</form>
                     </div>
                  </div>
                  <!-- END SAMPLE TABLE PORTLET-->
               </div>              
            </div>
           
            <!-- END PAGE CONTENT-->
         </div>
         <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
	<script>
		$(document).ready(function(){
			$("#form-semester").validate(
				{
					errorElement: 'span', //default input error message container
					errorClass: 'help-inline', // default input error message class
					focusInvalid: false, // do not focus the last invalid input
					ignore: "",
					highlight: function (element) { // hightlight error inputs
						$(element)
							.closest('.help-inline').removeClass('ok'); // display OK icon
						$(element)
							.closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group
					},

					unhighlight: function (element) { // revert the change dony by hightlight
						$(element)
							.closest('.control-group').removeClass('error'); // set error class to the control group
					},

					success: function (label) {
						label
							.addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon
						.closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group
					}
				}
			);
			
			$('#type').select2({
	            placeholder: "Select an option",
	            allowClear: true
	        });
		});
	</script>